home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-16 | 3.8 KB | 123 lines | [TEXT/CCL2] |
- ;;-*- Mode: Lisp; Package: CCL -*-
- ;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; graphic-items.lisp
- ;;
- ;; ©1989, Apple Computer, Inc
- ;;
- ;;
- ;; an abstract class of dialog-items which display, but can't be clicked.
- ;; graphic-dialog-items work by defining point-in-item-p to always
- ;; return nil.
- ;;
- ;; title-box-dialog-items are a sub-class of graphic-dialog-items which
- ;; are used for putting frames around areas in dialogs
- ;;
-
- ;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; Change History
- ;;
- ;; 04/28/93 mwp Release
- ;; 04/07/92 bill The interface-designer package is no more
- ;;-------------- 2.0
- ;; 10/15/91 bill window-font -> view-font
- ;;-------------- 2.0b3
- ;; 07/09/91 bill (provide 'graphic-items)
- ;;-------------- 2.0b2
-
- (in-package :ccl)
-
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (export '(graphic-dialog-item title-box-dialog-item) :ccl))
-
- (defclass graphic-dialog-item (dialog-item)
- ())
- (defclass title-box-dialog-item (graphic-dialog-item)
- ((title-box-width :initform 0 :accessor title-box-width)))
-
- ;;;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; graphic-dialog-items redefine point-in-click-region-p so that the
- ;; items aren't clickable (i.e., they never cover up other items)
- ;;
-
- (defmethod point-in-click-region-p ((item graphic-dialog-item) point)
- (if (and (editing-dialogs-p (view-window item))
- (call-next-method))
- (progn
- (do-dialog-items (item (view-container item))
- (unless (inherit-from-p item 'graphic-dialog-item)
- (when (view-contains-point-p item point)
- (return-from point-in-click-region-p nil))))
- t)
- nil))
-
-
- ;;;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; title-box-dialog-items are used for putting named frames around
- ;; areas in a dialog.
- ;;
-
- (defmethod install-view-in-window ((item title-box-dialog-item) dialog)
- (let* ((topleft (view-position item))
- (bottomright (add-points topleft (view-size item))))
- (rlet ((r :rect :topleft topleft
- :bottomright bottomright))
- (rset r :rect.top (- (rref r :rect.top) 8))
- (#_InvalRect :ptr r)))
- (call-next-method)
- (setf (title-box-width item)
- (string-width (dialog-item-text item)
- (or (view-font item)
- (view-font dialog)))))
-
- (defmethod set-view-font ((item title-box-dialog-item) new-font-spec)
- (setf (title-box-width item)
- (string-width (dialog-item-text item) new-font-spec))
- (call-next-method)
- (invalidate-view item))
-
- (defmethod set-dialog-item-text ((item title-box-dialog-item) new-text)
- (let ((my-dialog (view-window item)))
- (when my-dialog
- (setf (title-box-width item)
- (string-width new-text
- (or (view-font item)
- (view-font my-dialog))))
- (call-next-method)
- (view-focus-and-draw-contents item))))
-
- (defmethod view-draw-contents ((item title-box-dialog-item))
- (let* ((topleft (view-position item))
- (bottomright (add-points topleft (view-size item))))
- (with-pstrs ((p-title (dialog-item-text item)))
- (rlet ((r :rect :topleft topleft
- :bottomright bottomright))
- (#_FrameRect :ptr r)
- (rset r rect.left (+ (rref r rect.left) 4))
- (rset r rect.bottom (+ (rref r rect.top) 2))
- (rset r rect.right (+ (rref r rect.left)
- 4
- (title-box-width item)))
- (#_EraseRect :ptr r))
- (#_MoveTo :long (add-points topleft #@(6 5)))
- (#_DrawString :ptr p-title))))
-
- (provide 'graphic-items)
-
-
- #|
-
- (setq my-box (make-instance 'title-box-dialog-item
- :dialog-item-text "Buttons"
- :view-position #@(20 20)
- :view-size #@(100 100)))
-
- (setq my-dialog (make-instance 'dialog
- :view-size #@(200 125)
- :view-subviews (list my-box)))
-
- |#
-